package com.zdft.promotion.common.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class RestHttpClient {
	
	public final static int OK = 200;
	
	@Autowired
	RestTemplate restTemplate;
	
	public ResponseEntity<String> postForEntity(String url,String json){
		
		HttpHeaders headers = new HttpHeaders();
		headers.add("Accept", "application/json");// 请求头
		headers.setContentType(MediaType.APPLICATION_JSON);
		HttpEntity requestEntity = new HttpEntity(json, headers);
		
		return restTemplate.postForEntity(url, requestEntity, String.class);
		
	}

}
